package com.onedec.deptassemble.service.impl;

import com.onedec.deptassemble.dao.OnedecDeptDao;
import com.onedec.deptassemble.dao.OnedecEmpDao;
import com.onedec.deptassemble.entity.OnedecDept;
import com.onedec.deptassemble.entity.OnedecEmp;
import com.onedec.deptassemble.entity.OnedecEmpExample;
import com.onedec.deptassemble.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {
    @Resource
    private OnedecDeptDao deptDao;
    @Resource
    private OnedecEmpDao empDao;
    @Override
    public List<OnedecDept> getDepts() throws Exception {
        return deptDao.selectByExample(null);
    }
    @Override
    public List<OnedecEmp> getAdmins() throws Exception{
        OnedecEmpExample onedecEmpExample = new OnedecEmpExample();
        OnedecEmpExample.Criteria criteria = onedecEmpExample.or();
        criteria.andEmpRidBetween(2,10);
       return empDao.selectByExample(onedecEmpExample);
    }

    @Override
    public List<OnedecEmp> getDeptEmps(Integer did) throws Exception {
        OnedecEmpExample onedecEmpExample = new OnedecEmpExample();
        OnedecEmpExample.Criteria criteria = onedecEmpExample.or();
        criteria.andEmpDidEqualTo(did);
        return null;
    }
}
